package com.sinsz.c.context.support;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.Serializable;
import java.util.Map;

/**
 * 日志信息
 * @author chenjianbo
 * @date 2017/11/27
 */
public class LoggerData implements Serializable{


    private static final long serialVersionUID = -709809469523907408L;
    private long loggerTime;

    private LoggerEnum type;

    private String host;

    private String uri;

    private String method;

    private Map<String, String[]> params;

    private Map<String, String> headers;

    private String err;

    public long getLoggerTime() {
        return loggerTime;
    }

    public void setLoggerTime(long loggerTime) {
        this.loggerTime = loggerTime;
    }

    public LoggerEnum getType() {
        return type;
    }

    public void setType(LoggerEnum type) {
        this.type = type;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public Map<String, String[]> getParams() {
        return params;
    }

    public void setParams(Map<String, String[]> params) {
        this.params = params;
    }

    public String getErr() {
        return err;
    }

    public void setErr(String err) {
        this.err = err;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }

    public void setHeaders(Map<String, String> headers) {
        this.headers = headers;
    }

    @Override
    public String toString() {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
            e.printStackTrace(System.out);
        }
        return super.toString();
    }
}
